fix(metadata-protocol): boot hydration uses the shared package-scoped overlay registration (#4624) - #4635
Merged
Conversation
… overlay registration (#4624) loadMetaFromDb's non-object branch kept a THIRD inline copy of the overlay->SchemaRegistry rule with an UNSCOPED artifact lookup — the exact pre-#1828 shape: a name-colliding overlay grafted the first-registered package's _lock/_packageId/_provenance onto another package's row at boot (ADR-0048 gap). The branch now delegates to the ONE shared hydrateOverlayIntoRegistry (#4521), passing the row's own package_id, so the ADR-0048 package-scoped lookup applies at boot exactly as it does on the read-side hydration and the write-through. No other boot behaviour changes: artifacts-not-yet-loaded boot orders register the row unchanged (scoped and unscoped both find nothing), package-less rows keep the legacy best-effort graft, and the helper carries no environment gate so row selection is untouched. Pin test: two packages shipping the same-named artifact — boot hydration must graft each row's envelope from ITS OWN package (fails pre-fix with com.acme.a grafted onto com.acme.b's row). Fixes #4624 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4624
问题
loadMetaFromDb(启动水合)的非 object 分支保留着 overlay→SchemaRegistry 注册规则的第三份内联拷贝,且其 artifact 查找是无包作用域的(lookupArtifactItem(normalizedType, name),不带该行的package_id)——正是 #1828 在getMetaItems中修掉的 pre-ADR-0048 形态:当两个已安装的包发布同名type/name时,一条同名 overlay 行会在每次内核启动时,把先注册的那个包的_lock/_lockReason/_packageId/_provenance嫁接到另一个包的行上(composite 扫描按 Map 插入顺序 first-match)。绑定在包 B 下的定制行,启动后可能顶着包 A 的身份和锁。修复
按 issue 建议,将内联块替换为对 #4622 落地的共享实现
hydrateOverlayIntoRegistry的调用,并传入该行自己的record.package_id—— 一条规则、一份实现(读侧水合、#4521 写穿、启动水合三处共用),ADR-0048 的包作用域查找在启动时同样生效。按 issue/PM 要求逐项核查过的两个前提
getMetaItems的environmentId === undefined判断、写穿applyRegistryWriteThrough第 6031 行)。因此切换到 helper 不改变哪些行进入注册表:loadMetaFromDb的行选择完全由其查询决定,本 PR 未触碰。另注:包无绑定(
package_id IS NULL)的全局行保持遗留 best-effort first-match 嫁接语义,与读侧水合完全一致(pin test 第 3 例固定,断言故意宽松以免过度固定 first-match 顺序)。Pin test(修复前必失败)
packages/objectql/src/protocol-boot-hydration-scoped.test.ts—— 两个包(com.acme.a先注册、com.acme.b后注册)发布同名page/homeartifact,sys_metadata 中一条绑定com.acme.b的 overlay 行;启动水合后 bare-key 条目必须携带 B 的保护封套。在修复前的树上验证过失败:测试
pnpm --filter @objectstack/metadata-protocol test→ 25 files / 206 tests passedpnpm --filter @objectstack/objectql test→ 100 files / 1609 tests passed(含新增 3 例)pnpm --filter @objectstack/objectql typecheck→ exit 0(metadata-protocol 无 typecheck 脚本,系 ratchet ledger 中的既有 DEBT 条目;其 DTS 构建通过)范围外发现(已另行建 issue,未在本 PR 修)
loadMetaFromDb的 object 分支(约 8960 行)读取record.packageId || 'sys_metadata',而engine.find('sys_metadata')返回的是 snake_case 行键(package_id,与getMetaItems第 2588 行、repository 写入路径一致),故record.packageId恒为undefined——所有 object overlay 行一律以'sys_metadata'哨兵注册,包绑定在启动水合时丢失。详见新建 issue。Changeset
.changeset/boot-hydration-scoped-lookup.md(@objectstack/metadata-protocolpatch)。🤖 Generated with Claude Code
https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
Generated by Claude Code